package com.english.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.english.entity.Recharge;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

/**
 * 充值数据访问层
 *
 * @author wlq
 * @since 2025-08-04
 */
@Mapper
public interface RechargeMapper extends BaseMapper<Recharge> {

    /**
     * 根据学生ID统计充值次数（支付成功的）
     * @param studentId 学生ID
     * @return 充值次数
     */
    @Select("SELECT COUNT(*) FROM recharge WHERE student_id = #{studentId} AND status = 1")
    Integer countByStudentId(@Param("studentId") Long studentId);
}
